VintaSoft Imaging .NET SDK 14.1: Документация для .NET разработчика
Vintasoft.Imaging.Pdf.Drawing Namespace / PdfGraphics Class / BeginMarkedContent Methods / BeginMarkedContent(String,KeyValuePair<String,PdfBasicObject>[]) Method
Синтаксис Example Требования Смотрите также
В этом разделе
    BeginMarkedContent(String,KeyValuePair<String,PdfBasicObject>[]) Метод (PdfGraphics)
    В этом разделе
    Начинает последовательность помеченного содержимого со связанным списком свойств в потоке содержимого.
    Синтаксис
    'Declaration
    
    Public Overloads Sub BeginMarkedContent( _
    ByVal tag
    Объект имени, указывающий роль или значимость последовательности.
    As System.String, _
    ByVal ParamArray properties
    Массив, содержащий список свойств, содержащий дополнительную информацию, связанную с маркированным содержимым.
    As System.Collections.Generic.KeyValuePair(Of String,PdfBasicObject) _
    )
    public void BeginMarkedContent(
    System.String tag,
    params System.Collections.Generic.KeyValuePair<string,PdfBasicObject> properties
    )
    public: void BeginMarkedContent(
    System.String tag,
    params System.Collections.Generic.KeyValuePair<string,PdfBasicObject*>* properties
    )

    Parameters

    tag
    Объект имени, указывающий роль или значимость последовательности.
    properties
    Массив, содержащий список свойств, содержащий дополнительную информацию, связанную с маркированным содержимым.
    Пример

    Вот пример, показывающий, как создать помеченный PDF документ с помеченным содержимым со свойствами:

    
    ''' <summary>
    ''' Creates a tagged PDF document with marked content with properties.
    ''' </summary>
    Public Shared Sub CreateTaggedPdfWithProperties()
        ' create new PDF document
        Using document As New Vintasoft.Imaging.Pdf.PdfDocument()
            ' add new page to the PDF document
            document.Pages.Add(New System.Drawing.SizeF(250, 250))
    
            ' create marked information object
            Dim markInfo As New Vintasoft.Imaging.Pdf.Tree.PdfMarkInformation(document)
            markInfo.IsMarked = True
            ' add marked information object to the PDF document
            document.MarkedInformation = markInfo
    
            ' get graphics object associated with page
            Using graphics As Vintasoft.Imaging.Pdf.Drawing.PdfGraphics = document.Pages(0).GetGraphics()
                ' create properties for marked content
                Dim markedContentProperties As System.Collections.Generic.KeyValuePair(Of String, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject)() = New System.Collections.Generic.KeyValuePair(Of String, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject)() {New System.Collections.Generic.KeyValuePair(Of String, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject)("Subtype", New Vintasoft.Imaging.Pdf.BasicTypes.PdfName("Header")), New System.Collections.Generic.KeyValuePair(Of String, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject)("Attached", New Vintasoft.Imaging.Pdf.BasicTypes.PdfArray(document, New Vintasoft.Imaging.Pdf.BasicTypes.PdfName("Top"))), New System.Collections.Generic.KeyValuePair(Of String, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject)("Type", New Vintasoft.Imaging.Pdf.BasicTypes.PdfName("Pagination"))}
    
                ' begin the marked content with properties
                graphics.BeginMarkedContent("Artifact", markedContentProperties)
    
                ' get the PDF font
                Dim pdfFont As Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont = document.FontManager.GetStandardFont(Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman)
    
                ' draw a text string
                graphics.DrawString("Header text string", pdfFont, 12, New Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Green), New System.Drawing.PointF(25, 50))
    
                ' end the marked content
                graphics.EndMarkedContent()
            End Using
    
            ' save document
            document.SaveChanges("D:\testTaggedPdf.pdf")
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Creates a tagged PDF document with marked content with properties.
    /// </summary>
    public static void CreateTaggedPdfWithProperties()
    {
        // create new PDF document
        using (Vintasoft.Imaging.Pdf.PdfDocument document = new Vintasoft.Imaging.Pdf.PdfDocument())
        {
            // add new page to the PDF document
            document.Pages.Add(new System.Drawing.SizeF(250, 250));
    
            // create marked information object
            Vintasoft.Imaging.Pdf.Tree.PdfMarkInformation markInfo =
                new Vintasoft.Imaging.Pdf.Tree.PdfMarkInformation(document);
            markInfo.IsMarked = true;
            // add marked information object to the PDF document
            document.MarkedInformation = markInfo;
    
            // get graphics object associated with page
            using (Vintasoft.Imaging.Pdf.Drawing.PdfGraphics graphics = document.Pages[0].GetGraphics())
            {
                // create properties for marked content
                System.Collections.Generic.KeyValuePair<string, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject>[] markedContentProperties =
                    new System.Collections.Generic.KeyValuePair<string, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject>[]{
                        new System.Collections.Generic.KeyValuePair<string, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject>(
                            "Subtype", new Vintasoft.Imaging.Pdf.BasicTypes.PdfName("Header")),
                        new System.Collections.Generic.KeyValuePair<string, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject>(
                            "Attached", new Vintasoft.Imaging.Pdf.BasicTypes.PdfArray(document, new Vintasoft.Imaging.Pdf.BasicTypes.PdfName("Top"))),
                        new System.Collections.Generic.KeyValuePair<string, Vintasoft.Imaging.Pdf.BasicTypes.PdfBasicObject>(
                            "Type", new Vintasoft.Imaging.Pdf.BasicTypes.PdfName("Pagination"))
                    };
    
                // begin the marked content with properties
                graphics.BeginMarkedContent("Artifact", markedContentProperties);
    
                // get the PDF font
                Vintasoft.Imaging.Pdf.Tree.Fonts.PdfFont pdfFont = document.FontManager.GetStandardFont(
                    Vintasoft.Imaging.Pdf.Tree.Fonts.PdfStandardFontType.TimesRoman);
    
                // draw a text string
                graphics.DrawString(
                    "Header text string",
                    pdfFont,
                    12,
                    new Vintasoft.Imaging.Pdf.Drawing.PdfBrush(System.Drawing.Color.Green),
                    new System.Drawing.PointF(25, 50));
    
                // end the marked content
                graphics.EndMarkedContent();
            }
    
            // save document
            document.SaveChanges(@"D:\testTaggedPdf.pdf");
        }
    }
    
    

    Требования

    Целевые платформы: .NET 9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также